home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / amiga / plotting / gnuplot3.lzh / gnuplot / corplot.c < prev    next >
C/C++ Source or Header  |  1991-07-18  |  2KB  |  77 lines

  1. /* GNUPLOT - corplot.c */
  2. /*
  3.  * Copyright (C) 1986, 1987, 1990, 1991   Thomas Williams, Colin Kelley
  4.  *
  5.  * Permission to use, copy, and distribute this software and its
  6.  * documentation for any purpose with or without fee is hereby granted, 
  7.  * provided that the above copyright notice appear in all copies and 
  8.  * that both that copyright notice and this permission notice appear 
  9.  * in supporting documentation.
  10.  *
  11.  * Permission to modify the software is granted, but not the right to
  12.  * distribute the modified code.  Modifications are to be distributed 
  13.  * as patches to released version.
  14.  *  
  15.  * This software is provided "as is" without express or implied warranty.
  16.  * 
  17.  *
  18.  * AUTHORS
  19.  * 
  20.  *   Original Software:
  21.  *     Thomas Williams,  Colin Kelley.
  22.  * 
  23.  *   Gnuplot 2.0 additions:
  24.  *       Russell Lang, Dave Kotz, John Campbell.
  25.  *
  26.  *   Gnuplot 3.0 additions:
  27.  *       Gershon Elber and many others.
  28.  * 
  29.  * Send your comments or suggestions to 
  30.  *  pixar!info-gnuplot@sun.com.
  31.  * This is a mailing list; to join it send a note to 
  32.  *  pixar!info-gnuplot-request@sun.com.  
  33.  * Send bug reports to
  34.  *  pixar!bug-gnuplot@sun.com.
  35.  */
  36. #include <stdio.h>
  37. #include <process.h>
  38. #include <dos.h>
  39.  
  40. #define BOUNDARY 32768
  41. #define segment(addr) (FP_SEG(m) + ((FP_OFF(m)+15) >> 4));
  42. #define round(value,boundary) (((value) + (boundary) - 1) & ~((boundary) - 1))
  43.  
  44. char *malloc(),*realloc();
  45.  
  46. char prog[] = "gnuplot";
  47. char corscreen[] = "CORSCREEN=0";
  48.  
  49. main()
  50. {
  51. register unsigned int segm,start;
  52. char *m;
  53.     if (!(m = malloc(BOUNDARY))) {
  54.         printf("malloc() failed\n");
  55.         exit(1);
  56.     }
  57.     segm = segment(m);
  58.     start = round(segm,BOUNDARY/16);
  59.  
  60.     if (realloc(m,BOUNDARY+(start-segm)*16) != m) {
  61.         printf("can't realloc() memory\n");
  62.         exit(2);
  63.     }
  64.  
  65.     if ((segm = start >> 11) >= 8) {
  66.         printf("not enough room in first 256K\n");
  67.         exit(3);
  68.     }
  69.  
  70.     corscreen[sizeof(corscreen)-2] = '0' + segm;
  71.     if (putenv(corscreen))
  72.         perror("putenv");
  73.  
  74.     if (spawnlp(P_WAIT,prog,prog,NULL))
  75.         perror("spawnlp");
  76. }
  77.